package nl.jaapniek.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBManager {
	public static String DATABASE_NAAM = "myrdbms";
	private Connection connection;

	public DBManager() {

	}

	public Connection openConnection() {
		try {
			// Getting a connection to the newly started database
			Class.forName("org.hsqldb.jdbcDriver");
			// Default user of the HSQLDB is 'sa'
			connection = DriverManager.getConnection(
					"jdbc:hsqldb:hsql://localhost/" + DATABASE_NAAM, "sa", "");
			return connection;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return connection;
	}

	public void closeConnection() {
		if (connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

}
